/*
 * serial_unit.h
 *
 *  Created on: 2021年10月24日
 *      Author: zwr
 */

#ifndef INC_SERIAL_UNIT_H_
#define INC_SERIAL_UNIT_H_
/* dac spi pin */
#define CLK_H    GPIOSetBitValue(  0, 20,  1 )
#define CLK_L    GPIOSetBitValue(  0, 20,  0 )
#define SDA_H    GPIOSetBitValue(  0, 21,  1 )
#define SDA_L    GPIOSetBitValue(  0, 21,  0 )
#define CS_H     GPIOSetBitValue(  0, 22,  1 )
#define CS_L     GPIOSetBitValue(  0, 22,  0 )

/* sht20 configure*/
typedef enum{
  TRIG_T_MEASUREMENT_HM    = 0xE3, // command trig. temp meas. hold master
  TRIG_RH_MEASUREMENT_HM   = 0xE5, // command trig. humidity meas. hold master
  TRIG_T_MEASUREMENT_POLL  = 0xF3, // command trig. temp meas. no hold master
  TRIG_RH_MEASUREMENT_POLL = 0xF5, // command trig. humidity meas. no hold master
  USER_REG_W               = 0xE6, // command writing user register
  USER_REG_R               = 0xE7, // command reading user register
  SOFT_RESET               = 0xFE  // command soft reset
}SHT2xCommand;

typedef enum {
  SHT2x_RES_12_14BIT       = 0x00, // RH=12bit, T=14bit
  SHT2x_RES_8_12BIT        = 0x01, // RH= 8bit, T=12bit
  SHT2x_RES_10_13BIT       = 0x80, // RH=10bit, T=13bit
  SHT2x_RES_11_11BIT       = 0x81, // RH=11bit, T=11bit
  SHT2x_RES_MASK           = 0x81  // Mask for res. bits (7,0) in user reg.
} SHT2xResolution;

typedef enum {
  SHT2x_EOB_ON             = 0x40, // end of battery
  SHT2x_EOB_MASK           = 0x40, // Mask for EOB bit(6) in user reg.
} SHT2xEob;


typedef enum {
  SHT2x_HEATER_ON          = 0x04, // heater on
  SHT2x_HEATER_OFF         = 0x00, // heater off
  SHT2x_HEATER_MASK        = 0x04, // Mask for Heater bit(2) in user reg.
} SHT2xHeater;

typedef enum{
  HUMIDITY,
  TEMP
}SHT2xMeasureType;

typedef enum{
  I2C_ADR_W                = 0x80,   // sensor I2C address + write bit 1000 0000
  I2C_ADR_R                = 0x81    // sensor I2C address + read bit
}I2cHeader;
typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;
#endif /* INC_SERIAL_UNIT_H_ */
